/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.CRFunction;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Function;
import org.xtext.example.cr.cR.StandardFunction;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Function</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.FunctionImpl#getStandardFunction <em>Standard Function</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.FunctionImpl#getCrFunction <em>Cr Function</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FunctionImpl extends MinimalEObjectImpl.Container implements Function
{
  /**
   * The cached value of the '{@link #getStandardFunction() <em>Standard Function</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStandardFunction()
   * @generated
   * @ordered
   */
  protected StandardFunction standardFunction;

  /**
   * The cached value of the '{@link #getCrFunction() <em>Cr Function</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCrFunction()
   * @generated
   * @ordered
   */
  protected CRFunction crFunction;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected FunctionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.FUNCTION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public StandardFunction getStandardFunction()
  {
    return standardFunction;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetStandardFunction(StandardFunction newStandardFunction, NotificationChain msgs)
  {
    StandardFunction oldStandardFunction = standardFunction;
    standardFunction = newStandardFunction;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.FUNCTION__STANDARD_FUNCTION, oldStandardFunction, newStandardFunction);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setStandardFunction(StandardFunction newStandardFunction)
  {
    if (newStandardFunction != standardFunction)
    {
      NotificationChain msgs = null;
      if (standardFunction != null)
        msgs = ((InternalEObject)standardFunction).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.FUNCTION__STANDARD_FUNCTION, null, msgs);
      if (newStandardFunction != null)
        msgs = ((InternalEObject)newStandardFunction).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.FUNCTION__STANDARD_FUNCTION, null, msgs);
      msgs = basicSetStandardFunction(newStandardFunction, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.FUNCTION__STANDARD_FUNCTION, newStandardFunction, newStandardFunction));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CRFunction getCrFunction()
  {
    return crFunction;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCrFunction(CRFunction newCrFunction, NotificationChain msgs)
  {
    CRFunction oldCrFunction = crFunction;
    crFunction = newCrFunction;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.FUNCTION__CR_FUNCTION, oldCrFunction, newCrFunction);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCrFunction(CRFunction newCrFunction)
  {
    if (newCrFunction != crFunction)
    {
      NotificationChain msgs = null;
      if (crFunction != null)
        msgs = ((InternalEObject)crFunction).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.FUNCTION__CR_FUNCTION, null, msgs);
      if (newCrFunction != null)
        msgs = ((InternalEObject)newCrFunction).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.FUNCTION__CR_FUNCTION, null, msgs);
      msgs = basicSetCrFunction(newCrFunction, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.FUNCTION__CR_FUNCTION, newCrFunction, newCrFunction));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.FUNCTION__STANDARD_FUNCTION:
        return basicSetStandardFunction(null, msgs);
      case CRPackage.FUNCTION__CR_FUNCTION:
        return basicSetCrFunction(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.FUNCTION__STANDARD_FUNCTION:
        return getStandardFunction();
      case CRPackage.FUNCTION__CR_FUNCTION:
        return getCrFunction();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.FUNCTION__STANDARD_FUNCTION:
        setStandardFunction((StandardFunction)newValue);
        return;
      case CRPackage.FUNCTION__CR_FUNCTION:
        setCrFunction((CRFunction)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.FUNCTION__STANDARD_FUNCTION:
        setStandardFunction((StandardFunction)null);
        return;
      case CRPackage.FUNCTION__CR_FUNCTION:
        setCrFunction((CRFunction)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.FUNCTION__STANDARD_FUNCTION:
        return standardFunction != null;
      case CRPackage.FUNCTION__CR_FUNCTION:
        return crFunction != null;
    }
    return super.eIsSet(featureID);
  }

} //FunctionImpl
